package com.byteblogs.helloblog.endpoint;

import com.byteblogs.helloblog.dto.HttpResult;
import com.byteblogs.helloblog.integration.ByteBlogsClient;
import com.byteblogs.helloblog.integration.dto.EmailDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author: zsg
 * @description:
 * @date: 2019/12/22 10:02
 * @modified:
 */
@RestController
@RequestMapping("/byteblogs")
public class ByteBlogsEndPoint {

    @Autowired
    private ByteBlogsClient byteBlogsClient;

    @GetMapping("/posts")
    public HttpResult getPostsList(@NotNull @RequestParam(value = "pagingQuery.pageIndex", required = false) Integer pageIndex,
                                   @NotNull @RequestParam(value = "pagingQuery.pageSize", required = false) Integer pageSize) {
        return byteBlogsClient.getPostsList(pageIndex, pageSize);
    }

    @PostMapping("/email/v1/send")
    public HttpResult sendRegisterEmail(@RequestBody EmailDTO emailDTO) {
        return byteBlogsClient.sendRegisterEmail(emailDTO);
    }

    @GetMapping("/user/v1/count")
    public HttpResult countPerson() {
        return byteBlogsClient.countPerson();
    }

    @GetMapping("/user-views/v1/chart")
    public HttpResult getViewsChart() {
        return byteBlogsClient.getViewsChart();
    }
}
